package com.steven.realServer.dao;

import com.steven.realServer.pojo.SchoolInfo;
import com.steven.realServer.pojo.UserDetail;
import com.steven.realServer.pojo.UserInfo;
import com.steven.realServer.pojo.UserStatus;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface IdentifyDao {

    @Select("SELECT * FROM school_info where schoolName like CONCAT(#{schoolName},'%') order by convert(schoolName using gbk) asc")
    public List<SchoolInfo> searchSchool(String schoolName);

    @Select("SELECT * FROM user_detail where uid=#{uid}")
    public List<UserDetail> searchUserDetail(Long uid);

    @Insert("INSERT INTO user_detail(uid,imageUrl) VALUE(#{uid},#{imageUrl})")
    public int addUserIdentityImage(Long uid,String imageUrl);

    @Update("UPDATE user_detail set imageUrl=#{imageUrl} where uid=#{uid}")
    public int updateUserIdentityImage(Long uid,String imageUrl);

    @Insert("INSERT INTO user_detail(uid,uname,school,college,judge,schoolType,startYear,userType) VALUE(#{uid},#{uname},#{school},#{college},#{judge},#{schoolType},#{startYear},#{userType})")
    public int addUserDetail(Long uid, String uname, String school, String college, String judge, String schoolType, Long startYear, String userType);

    @Update("UPDATE user_detail set uname=#{uname},school=#{school},college=#{college},judge=#{judge},schoolType=#{schoolType},startYear=#{startYear},userType=#{userType},status=0 where uid=#{uid}")
    public int updateUserDetail(Long uid, String uname, String school, String college, String judge, String schoolType, Long startYear, String userType);

    @Update("UPDATE user_detail set status=#{status} where uid=#{uid} and status=0")
    public int updateUserIdentifyStatus(Long uid, int status);

    @Select("SELECT * FROM user_detail where status=0")
    public List<UserDetail> queryToBeConfirm();
}
